package com.bodu.exchange.service.impl;

import com.bodu.exchange.entity.vo.ExchangeBillVo;
import com.bodu.core.entity.ParamReq;
import com.bodu.exchange.entity.request.ExchangeBillRequest;
import com.bodu.exchange.mapper.ExchangeBillMapper;
import com.bodu.exchange.service.ExchangeBillService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
* 账单 Service impl
* @author Administrator
*/
@Service
public class ExchangeBillServiceImpl implements ExchangeBillService {

   @Resource
   private ExchangeBillMapper exchangeBillMapper;

   @Override
   public ExchangeBillVo getModel(Long id) {
      return  exchangeBillMapper.getModel(id);
   }

   @Transactional
   @Override
   public Long save(ExchangeBillRequest request) {
      exchangeBillMapper.save(request);
      return request.getId();
   }

   @Transactional
   @Override
   public Long update(ExchangeBillRequest exchangeBillRequest) {
      exchangeBillMapper.update(exchangeBillRequest);
      return exchangeBillRequest.getId();
   }

   @Override
   public List<ExchangeBillVo> listPage(ParamReq<ExchangeBillRequest> params) {
      params.setStartIndex((params.getCurrent() -1 ) * params.getSize());
      return exchangeBillMapper.listPage(params);
   }

   @Override
   public Integer countPage(ParamReq<ExchangeBillRequest> params) {
       return exchangeBillMapper.countPage(params);
   }

   @Override
   public Integer updateDelFlagById(Long id, Integer delFlag) {
       return exchangeBillMapper.updateDelFlagById(id, delFlag);
   }
}
